<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>获取 url 参数</title>
</head>
<body>

	<div id="div1">
		<div id="div11">11</div>
		<div id="div12">12</div>
	</div>
	<div id="div2">
		<div id="div21">21</div>
		<div id="div22">22</div>
	</div>
<script>
function formatDate(date, format) {
	let addZero = function (data) {
        return ('00' + data).slice(-2);
    }

	let obj = {
		'yyyy': date.getFullYear(),
		'yy': date.getFullYear() % 100,
		'MM': addZero(date.getMonth() + 1),
        'M': date.getMonth() + 1,
        'dd': addZero(date.getDate()),
        'd': date.getDate(),
        'HH': addZero(date.getHours()),
        'H': date.getHours(),
        'hh': addZero(date.getHours() % 12),
        'h': date.getHours() % 12,
        'mm': addZero(date.getMinutes()),
        'm': date.getMinutes(),
        'ss': addZero(date.getSeconds()),
        's': date.getSeconds(),
        'w': function () {
            arr = ['日', '一', '二', '三', '四', '五', '六']
            return arr[date.getDay()]
        }()
	};

	for (let i in obj) {
        format = format.replace(i, obj[i]);
    }
    return format;
}
console.log(formatDate(new Date(1409894060000), 'yyyy-MM-dd HH:mm:ss 星期w'))
</script>

</body>
</html>